/*
 * @Des: 字典管理API
 * @Author: jin_yc
 * @Date: 2019-11-19 11:45:51
 * @LastEditor: jin_yc
 * @LastEditTime: 2021-09-17 14:13:47
 */
import request from '@/utils/request'

/**
 * @description: 查询字典列表-分页
 */
export function getDic (data) {
  return request({
    url: '/sys-system/dictionary/page',
    method: 'get',
    params: data
  })
}
/**
 * @description: 查询字典详情列表
 * @param {pId} 字典主键
 */
export function getDicDetail (data) {
  return request({
    url: '/sys-system/dictionary/child/list',
    method: 'get',
    params: data
  })
}
//获取指定code的所有语言翻译
export function getAllDicDetail (data) {
  return request({
    url: '/sys-system/dictionary/detail',
    method: 'get',
    params: data
  })
}
/**
 * @description: 新增字典
 */
export function addDic (data) {
  return request({
    url: '/sys-system/dictionary',
    method: 'post',
    data: data,
  })
}
/**
 * @description: 编辑字典
 */
export function addEditDic (data, type) {
  return request({
    url: '/sys-system/dictionary',
    method: type == 'add' ? 'post' : 'put',
    data: data,
  })
}
/**
 * @description: 删除字典
 */
export function deleteDic (id) {
  return request({
    url: '/sys-system/dictionary',
    method: 'delete',
    params: { id }
  })
}

/**
 * @description: 保存、更新字典详情列表（全量跟新）
 */
export function addEditDicDetail (data, type) {
  return request({
    url: '/sys-system/dictionary',
    method: type == 'add' ? 'post' : 'put',
    data: data,
    transformRequest: [
      data => {
        return data
      }
    ],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * @description: 删除字典详情
 * @param {id} 字典详情id 
 */
export function deleteDicDetail (data) {
  return request({
    url: '/sys-system/dictionary/detail',
    method: 'delete',
    params: data
  })
}
//多语言键值详情排序
export function sort (data) {
  return request({
    url: '/sys-system/dictionary/detail/sort',
    method: 'post',
    data: data
  })
}
//查询字典详情列表(多语言)
export function getLangDicDetail (data) {
  return request({
    url: '/sys-system/dictionary/detail/code',
    method: 'get',
    params: data
  })
}
/**字典导出 */
export function exportDic (data) {
  return request({
    url: '/sys-system/dictionary/export',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}
/**字典导入 */
export function importDic (data) {
  return request({
    url: '/sys-system/dictionary/import',
    method: 'post',
    data: data
  })
}